/*
 * Created on 07.11.2006 by leck
 *
 */
package de.devisnik.shifting.impl;

import de.devisnik.shifting.IPuzzle;

public class MoveFactory {

    private final IPuzzle itsGame;
    private final IMove itsLeft;
    private final IMove itsRight;
    private final IMove itsUp;
    private final IMove itsDown;

    public MoveFactory(IPuzzle game) {
        itsGame = game;
        itsLeft = new Move(-1, 0, itsGame);
        itsRight = new Move(1, 0, itsGame);
        itsUp = new Move(0, 1, itsGame);
        itsDown = new Move(0, -1, itsGame);
    }

    public IMove getLeft() {
        return itsLeft;
    }

    public IMove getRight() {
        return itsRight;
    }

    public IMove getUp() {
        return itsUp;
    }

    public IMove getDown() {
        return itsDown;
    }

    public IMove getInverse(IMove move) {
        if (move == itsLeft) {
            return itsRight;
        }
        if (move == itsRight) {
            return itsLeft;
        }
        if (move == itsUp) {
            return itsDown;
        }
        if (move == itsDown) {
            return itsUp;
        }
        throw new IllegalStateException();
    }

}
